package sample.mdd.userinfo.client;

import org.goodsl.mdd.gwt.box.client.BoxDescService;
import org.goodsl.mdd.gwt.box.client.BoxDescServiceAsync;
import org.goodsl.mdd.gwt.box.shared.BoxDesc;
import org.goodsl.mdd.gwt.box.shared.SegDesc;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class UInfo implements EntryPoint {
	/**
	 * The message displayed to the user when the server cannot be reached or
	 * returns an error.
	 */
//	private static final String SERVER_ERROR = "An error occurred while "
//			+ "attempting to contact the server. Please check your network "
//			+ "connection and try again.";

	private final BoxDescServiceAsync boxDescService = GWT
			.create(BoxDescService.class);
	

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {

		
		//simon add
		boxDescService.getBoxDesc("sample.mdd.userinfo.UserInfo", 
				new AsyncCallback<BoxDesc>() {
					public void onFailure(Throwable caught) {}
					public void onSuccess(BoxDesc boxDesc) {
						for(SegDesc seg : boxDesc.segList){
							TextBox txtBox = new TextBox();
							Label label = new Label(seg.alias+":");
							RootPanel.get(seg.name + "_anchor").add(txtBox);
							RootPanel.get(seg.name + "_label").add(label);
						}
					}
				});
		
		
		// end simon add 		
	}
}
